package structure;



public class LinkList {

    private class Node {
        int element;
        Node next;

        public Node(int element) {
            this.element = element;
            this.next = null;
        }
    }

    private Node head;

    public LinkList() {
        this.head = null;
    }

    // 链表添加元素
    public void add(int element) {
        Node node = new Node(element);
        if (head == null){
            head = node;
            return;
        }
        Node cur = head;
        while (cur.next != null){
            cur = cur.next;
        }
        cur.next = node;
    }

    // 链表查找元素
    public Node find(int element) {
        Node cur = head;
        while (cur != null){
            if (cur.element == element){
                return cur;
            }
            cur = cur.next;
        }
        return null;
    }

}
